/**
 * Coryright 2015-2020 www.eyaomall.cn
 * All rights reserved.
 * @author tumingjun
 * @date 2016年9月20日
 *
 */

package com.eyaomall.wxmanage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eyaomall.wxmanage.model.po.Invoice;
import com.eyaomall.wxmanage.model.pojo.ResFlag;
import com.eyaomall.wxmanage.model.vo.InvoiceVO;
import com.eyaomall.wxmanage.service.InvoiceService;
import com.lycheeframework.core.cmp.api.http.GsnData;
import com.lycheeframework.core.cmp.api.http.GsnResponse;
import com.lycheeframework.core.cmp.kit.PageHTTPObject;

/**
 * 发票管理
 * @author tumingjun
 *
 */

@Controller
@RequestMapping("invoice")
public class InvoiceController {

	@Autowired
	private InvoiceService invoiceService;
	
	/**
	 * 跳转到页面
	 * @return
	 */
	@RequestMapping("index")
	public String index(){
		
		return "invoice/index";
	}
	
	/**
	 * 分页查询
	 * @param invoice
	 * @return
	 */
	@RequestMapping("page_data")
	public @ResponseBody GsnData pageDate(InvoiceVO invoiceVO,PageHTTPObject httpObject){
		
		return GsnResponse.toData(invoiceService.page_data(invoiceVO,httpObject));
	}
	
	/**
	 * 拒绝开票
	 * @param invoiceId
	 * @param memo
	 * @return
	 */
	@RequestMapping("refuse")
	public @ResponseBody GsnData refuse(Integer invoiceId, String memo){
		
		return GsnResponse.toData(new ResFlag(invoiceService.refuse(invoiceId,memo)));
	}
	
	/**
	 * 同意开票
	 * @param invoiceId
	 * @return
	 */
	@RequestMapping("agree")
	public @ResponseBody GsnData agree(Integer invoiceId){
		
		return GsnResponse.toData(new ResFlag(invoiceService.agree(invoiceId)));
	}
	
}
